namespace WebinatorTest.IntegrationTests
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using BaseTests;
    using NUnit.Framework;
    using Webinator;

    [TestFixture]
    [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed. Suppression is OK here.")]
    public class SmokeTests : WebDriverBaseTest
    {
        /// <summary>
        /// Runs before each test
        /// </summary>
        [SetUp]
        public void SetupWebDriver()
        {
            Web.GoToUrl("http://localhost:8181/TestFiles/HighlighterTest.html");
        }

        [Test]
        public void TestHighlighting()
        {
            ////Web.Log.ChangeOutputPath(Web.Log.outputPath + System.Reflection.MethodBase.GetCurrentMethod().Name);

            Web.DisplayMessageInBrowser("Beginning test...", 1000);
            Web.SendKeys(LocateBy.Xpath("html/body/input[1]"), "textbox");
            Web.SendKeys(LocateBy.Xpath("html/body/textarea"), "textarea");

            Web.Click(LocateBy.Xpath("//input"));

            Web.SelectCheckbox(LocateBy.Checkbox(SelectBy.Text("checkbox 3")), true);
            Web.SelectCheckbox(LocateBy.Checkbox(SelectBy.Index(4)), true);

            Web.SelectRadio(LocateBy.Radio(SelectBy.PartialText("3")));
            Web.SelectListItem(LocateBy.Xpath("html/body/select"), SelectBy.Text("item 3"));

            var selected = Web.GetSelectedListItem(LocateBy.Xpath("html/body/select"));
            Console.WriteLine(selected.Index);
            Console.WriteLine(selected.Text);
            Console.WriteLine(selected.Value);

            Web.Click(LocateBy.Xpath("html/body/table/tbody/tr[3]/td[3]/div"));
            Web.Click(LocateBy.Xpath("html/body/input[2]"));
            Web.DisplayMessageInBrowser("Test completed.");
        }

        [Test]
        public void VerifyGetText()
        {
            var text = Web.VisibleText();
            Assert.IsTrue(text.Contains("Lorem ipsum dolor sit amet"));
        }
    }
}